{include file="public/header" /}
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 资讯中心 <span class="c-gray en">&gt;</span> 资讯管理 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<form action="" method="get">
		<div class="text-c"> 
			<input type="text" class="input-text" style="width:250px" placeholder="资讯名称" 
			value="{:input('word')}" name="word">
			<button type="submit" class="btn btn-success radius"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
		</div>
	</form>

	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a href="javascript:;" onclick="member_add('添加资讯','{:url('news_add')}')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加资讯</a></span> 
	<span class="r">共有数据：<strong id="count">{$count}</strong> 条</span> </div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th width="100">ID</th>
				<th width="250">标题</th>
				<th width="250">描述</th>
				<th width="50">类型</th>
				<th width="100">发布时间</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			{volist name="list" id="v"}
				<tr class="text-c" id="tr{$v.id}">
					<td><input type="checkbox" value="{$v.id}" name="del[]"></td>
					<td>{$v.id}</td>
					<td>{$v.title}</td>
					<td>{$v.desc}</td>
					<td>{if condition="$v.type eq 0"}公司简介{else/}公告{/if}</td>
                    <td>{$v.add_time|date="Y-m-d H:i:s"}</td>
					<td class="td-manage">
						<a title="编辑" href="javascript:;" 
						onclick="member_add('添加资讯','{:url('news_add',array('id'=>$v['id']))}')" class="ml-5" style="text-decoration:none">
						<i class="Hui-iconfont">&#xe6df;</i></a>
						<a title="删除" href="javascript:;" onclick="member_del(this,{$v['id']})" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
				</tr>
			{/volist}
		</tbody>
	</table>
	<div class="page text-r mt-10">
		{$page}
	</div>
	</div>
</div>
{include file="public/footer" /}

<script type="text/javascript">

/*资讯-添加*/
function member_add(title,url,w,h){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*资讯-删除*/
function member_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.post("{:url('news_del')}",{id:id},function(data){
			if(data.status == 'y'){
				layer.msg(data.info,{icon:1,time:1000});
				$(obj).parents("tr").remove();
				$("#count").text(data.count);
			}else{
				layer.msg('删除失败- -!',{icon:2,time:1000});
			}
		},'json');
	});
}

//批量删除
function datadel(){
 var id='';	
 $("input[name='del[]']:checked").each(function(){
 	id += $(this).val()+',';
 });

 if(id == ''){
 	layer.msg('必须选择资讯哦!',{icon:2,time:1000});
 	return false;
 }
 layer.confirm('确认要删除吗？',function(index){
 	$.post("{:url('news_del')}",{id:id},function(data){
		if(data.status == 'y'){
			//循环当前选择的框
			$("input[name='del[]']:checked").each(function(){
				//删除当前选择的框
				$(this).parents('tr').remove();
			});
			layer.msg(data.info,{icon:1,time:1000});
			$("#count").text(data.count);
		}else{
			layer.msg(data.info,{icon:2,time:1000});
		}
	});
 });
}
</script> 
</body>
</html>